<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('查询通话记录')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            流水号：<input type="text" name="wsCode"/>
                        </li>
                        <li>
                            来电号码：<input type="text" name="fromTelA"/>
                        </li>
                        <li>
                            来电人：<input type="text" name="fromName"/>
                        </li>
                        <li>
                            来电内容：<input type="text" name="fmContent"/>
                        </li>
                        <li>
                            用户名：<input type="text" name="liftWorkNo"/>
                        </li>
                        <li>
                            接听时间：
                            <input class="workTheme" type="text" name="startTime">
                            <span class="glyphicon glyphicon-calendar" style="margin-right: 5px;margin-left: -20px"></span>
                            一 <input class="glyphicon glyphicon-calendar workTheme" type="text" name="endTime">
                            <span class="glyphicon glyphicon-calendar" style="margin-left: -20px;margin-right: 10px"></span>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>


        <div class="col-sm-12 select-table table-striped">
            <a class="btn btn-warning" onclick="exportSelected()">
                <i class="fa fa-download"></i> 导出
            </a>
            <table id="bootstrap-table" class="table-striped"></table>
        </div>
    </div>
</div>
<script th:src="@{/ajax/libs/layui/laydate.js}"></script>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">

    var prefix = ctx + "system/lookup";

    $(function () {
        var options = {
            url: prefix + "/telGetAllList",
            detailUrl: prefix + "/telGetDetail/{id}",
            sortName: "pkId",
            sortOrder: "desc",
            uniqueId: "myPkVal",
            exportUrl: prefix + "/export",
            modalName: "通话记录",
            fixedColumns: true,
            fixedNumber: 2,
            fixedRightNumber: 1,
            columns: [{
                checkbox: true
            },
                {field: 'pkId', title: 'pkid', visible: false},
                {field: 'wsCode', title: '流水号', align: 'center', halign: 'center', sortable: true},
                {field: 'liftTelNo', title: '分机号', align: 'center'},
                {field: 'liftWorker', title: '接听人', align: 'center'},
                {field: 'fmAreaName', title: '地区', align: 'center', sortable: true},
                {field: 'fromTelA', title: '来电号码', align: 'center', halign: 'center', sortable: true},
                {field: 'fromName', title: '来电人', align: 'center', sortable: true},
                {field: 'fromTime', title: '接听时间', align: 'center'},
                {field: 'wfSltKey', title: '主题', align: 'center', halign: 'center'},
                {
                    field: 'hideTel', title: '电话是否隐藏', align: 'center', sortable: true,
                    formatter: function (value) {
                        return value == 5 ? '<span class="spRed">是</span>' : '否';
                    }
                },
                {
                    field: 'stateFlag',
                    title: '当前状态',
                    align: 'center',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return fmtTelGetState(value, row, index);
                    }
                },
                {
                    field: 'openX',
                    title: '工单状态',
                    align: 'center',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return fmtTelOpenXState(value, row, index);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-outline btn-xs " href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.pkId + '\')">查看</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function fmtTelOpenXState(value, row, index) {
        var rtn = value;
        var myVal = parseInt(value);
        switch (myVal) {
            case 2:
                rtn = '<div class="spDGray">终结件</div>';
                break;
            case 1:
                rtn = '<div class="spDGray">1</div>';
                break;
            case 0:
                rtn = '<div class="spDGray">0</div>';
                break;
            default:
                break;
        }
        return rtn;
    }

    function exportSelected() {
        var pkId = $.table.selectColumns("pkId");
        var dataParam = $("#post-form").serializeArray();
        var tipMsg = "确定导出所有数据吗？";
        if ($.common.isNotEmpty(pkId)) {
            tipMsg = "确定导出勾选" + pkId.length + "条数据吗？";
            dataParam.push({name: "twsf", value: pkId});
        }
        $.modal.confirm(tipMsg, function () {
            $.post(prefix + "/exportData", dataParam, function (result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                } else {
                    $.modal.alertError(result.msg);
                }
            });
        });
    }

    laydate.render({
        elem: '.workTheme', //指定元素
        format: 'yyyy-MM-dd',
        type: 'date'
    });
</script>
</body>
</html>